package org.geekbang.time;

import lombok.extern.slf4j.Slf4j;

import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Slf4j
public class SingletonDemo {
    static Singleton singleton;

    public static ExecutorService executorService = Executors.newFixedThreadPool(5);

    public static void main(String[] args) {
        executorService.execute(() -> getInstance());
    }


    public static Singleton getInstance() {
        if (Objects.isNull(singleton)) {
            synchronized (Singleton.class) {
                log.info("实例化对象~~~");
                singleton = new Singleton();
            }
        }
        return singleton;
    }
}



class Singleton{

}